-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UMD bundle for Kedro-Viz #2256
Conversation
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
…at/umd-viz-bundle Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Hi Team, I am providing some notes and updates on the kedro-viz bundle processing. I have few questions and will need some discussion before we publish the bundle. Summary: We will have 2 bundles -
In notebook use case we will construct a HTML and refer the production bundle via CDN as below in our backend implementation -
Question: If we decide on adding
cc: @rashidakanchwala @astrojuanlu @jitu5 NOTE: Total umd folder size including dev and prod is around 13MB. If we do not want traceback to detect errors, we can ignore the dev bundle. Exploration: UMD bundle optimizations and next steps: Analysis was done using Started with a 12MB parsed size bundle without any optimizations and 5MB minified bundle Vendor libraries in the bundle - Major chunk being - plotly, react-dom, loadash, @apollo/client Some optimizations - Below are the plotly references in the codebase:
After basic optimizations like tree shaking, sideEffects, minimizer and dropping console, comments After optimizations like making external dependencies (plotly), tree shaking, sideEffects, minimizer and dropping console, comments Final prod bundle size (1.51MB) -
NOTE: Adding more optimizations like - devtool: 'nosources-source-map', compression-webpack-plugin (using Brotli algo) apart from Terser did not impact bundle size For your information:
Dev Bundle (2.66 MB) with traceback kedro-viz.development.min.js.map (8.4MB) - We need a dev bundle for debugging DevBundle traceback in devTools Some known errors -
Testing: Testing demo_project in notebook - Snippet: from src.demo_project.pipeline_registry import register_pipelines
demo_pipe = register_pipelines()
NotebookVisualizer().show(pipeline=demo_pipe, options={ "display": {
"expandPipelinesBtn": False,
"exportBtn": False,
"globalNavigation": False,
"labelBtn": False,
"layerBtn": False,
"metadataPanel": True,
"miniMap": False,
"sidebar": False,
"zoomToolbar": False,
},
"expandAllPipelines": False,
"behaviour": {
"reFocus": False,
},
"theme": "dark"}) Next steps: After the initial bundle release
Thank you |
This is amazing work 🔥 thank you @ravi-kumar-pilla! What you describe makes me think that maybe we could try to separate the flowchart rendering part from the rest of the Viz frontend in a separate library, that would then be used by Viz. If I'm picturing this correctly, the flowchart rendering part wouldn't need to access local storage, browser history etc, so on the notebook we could use just that without fundamentally changing the architecture of the Kedro Viz web application. How does this sound? Otherwise, the efforts to reduce the bundle size are promising but the other issues remain (weird distortion, inability to run on an iframe, url mangling) |
Hi @ravi-kumar-pilla, @astrojuanlu This is amazing spike work @ravi-kumar-pilla —it has given us a lot to think about. I really appreciate the effort you’ve put into it We need to evaluate maintainability, effort vs. impact, and alignment with future Kedro-Viz developments. Given that the second half of 2025 will focus on the Pipeline Editor, which will be a major architectural shift, I think we should take a step back and plan PS sessions to align on the best direction for Kedro-Viz. Next Steps, can we do a PS session:
and also another session on :-
|
Good points @rashidakanchwala , let's continue the conversation in #1993 |
…at/umd-viz-bundle Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
Signed-off-by: ravi_kumar_pilla <[email protected]>
1 more thing @ravi-kumar-pilla , could you add a bit more detail around why UMD and not ESM? Just for future reference. My very basic understanding is that "ESM is the best module format thanks to its simple syntax, async nature, and tree-shakeability", whereas "UMD works everywhere and usually used as a fallback in case ESM does not work". https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm |
Hi @astrojuanlu , Yes the basic difference is what you have mentioned here. I tried using the esm bundle but could not get the app running as I mentioned in my comment above. There needs some more changes to the app for the bundle to work. I can have a look at it now. For the initial release, I thought we can go ahead with the UMD bundle since it is working fine and it is widely compatible with older environments. I have added the tree shaking optimization to the umd bundle which makes is more efficient (esm provides this by default), so our bundle is closer to esm with these optimizations. I will experiment today and provide more details on the esm bundle. Thank you |
Hi @astrojuanlu , I tested with esm module and made some changes. It is working now but we are unable to split the js into chunks (i.e., vendors.js and kedro-viz.js). This is not a big issue. As you might already know that esm is pretty new but it is considered the new standard for bundling. Even React19 dropped UMD and adopted ESM workflows. So we can go ahead with ESM for the initial release and if users face any compatibility issues, we can fallback to UMD. Also, I made React, React-DOM, lodash and plotly as externals. The pros of doing this is it reduces bundle size (1.3MB) and makes the kedro-viz bundle independent of React version. The cons are, since we do not yet support React19, if users directly use the esm bundle, they might face issues. For the notebook usecase, this is not an issue as we build the template in the backend and make sure the versions match. @jitu5 do you think we should bundle the external dependencies together so it would be easy for anyone to directly use the bundle ( if we include the above dependencies it would be 1.5MB, plotly can still be external ) ? Thank you |
closing this in favor of #2268 |
Description
Add a UMD Kedro-Viz bundle to be used directly in a html document.
Development notes
make version
, i.e., add a step to update this folder when we do a new releaseQA notes
make version VERSION=10.3.0
ornpm run build:umd
. Discard all the changes after testingChecklist
RELEASE.md
file